package com.dunsk.eureka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication {
    public static void main(String[] args) {
        try{
            ConfigurableApplicationContext applicationContext=SpringApplication.run(EurekaApplication.class, args);
            Environment env = applicationContext.getEnvironment();
            String ip = InetAddress.getLocalHost().getHostAddress();
            String port = env.getProperty("server.port");
            String property = env.getProperty("server.servlet.context-path");
            String path = property == null ? "" :  property;
            System.out.println(
                    "\n\t" +
                            "----------------------------------------------------------\n\t" +
                            "Application Xai-Web-Boot is running! Access URLs:\n\t" +
                            "Local: \t\thttp://localhost:" + port + path + "\n\t" +
                            "External: \thttp://" + ip + ":" + port + path + "\n\t" +
                            "------------------------------------------------------------");
        }catch (Throwable e){
            e.printStackTrace();
        }

    }
}
